%!TEX program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[10pt,a4paper]{article} 
\usepackage{ctex} % 中文支持
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry} % 页边距
\usepackage{amsmath, amssymb} % 数学公式与符号
\usepackage{graphicx}
\usepackage{pythonhighlight}
\usepackage{url} 


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 插入代码相关宏包
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\usepackage{color}

% 设置列表的样式
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}

\lstset{style=mystyle}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{titling}
\setlength{\droptitle}{-2cm} % 标题上移
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\author{221330100 WLQ }
\title{数学建模实验作业 \\ Python使用入门习题 - 第10题 }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\maketitle

%\begin{abstract}
%Python编程练习
%\end{abstract}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\setcounter{tocdepth}{2}
%\renewcommand\contentsname{目录}
%
%\renewcommand {\baselinestretch} {1.3}\normalsize 
%\tableofcontents 
%\renewcommand {\baselinestretch} {1.0}\normalsize


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{问题}

某容器内侧是由曲线 $x^2+y^2=4y(1\le y\le 3)$ 与 $x^2+y^2=4(y\le 1)$ 绕$y$轴旋转一周而成的曲面。求容器的体积。若将容器内盛满的水从容器顶部全部抽出，至少需要做多少功？

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{解答}

\subsection{第一部分}

先画出容器的图形。这是两个有部分重叠的圆。
先使用极坐标画出两个半径为2的圆周。
然后按题目条件画出一些水平的线段，表示容器内盛水的部分。

\begin{figure}[ht!]
\centering
\includegraphics[height=8cm, width=12cm]{ti-2-10.png}
\caption{第10题的容器储水示意图}
\end{figure}

\lstinputlisting[language=Python]{ex_2_10_a.py}

\subsection{第二部分}

接下来计算将容器内的所有水提升到顶部，克服重力需要做的功。
注意容器顶部在 $y=3$ 所在的水平线上。
不同水平层位上的水的提升高度是不一样的，
不同水平层位上的水的重量也是不一样的，
因此需要使用积分来计算总的功。
记重力加速度为 $g=9.8\, m/s^2$. 
记水的密度为 $\rho = 1000\, kg/m^3$. 

正如在画图时所体现的，将纵坐标 $y$ 分成 $[-2,1]$ 与 $[1,3]$ 两个区间。

\begin{enumerate}
\item[(1)]  当 $-2\le y\le 1$ 时，横截面是一个半径为 $ x = \sqrt{4-y^2}$
的圆。其面积为 $$ S(y)=\pi x^2 = \pi(4-y^2). $$
设高度为 $y$ 的一层薄薄的水的厚度为 $dy$. 因此这部分的水的体积为 
$$
dV = \pi (4-y^2)dy. 
$$

\item[(2)]  当 $1\le y\le 3$ 时，横截面是一个半径为 $ x = \sqrt{4y-y^2}$
的圆。其面积为 $$ S(y)=\pi x^2 = \pi(4y-y^2). $$
高度为 $y$ 的一层厚度为 $dy$ 的薄薄的水的体积为 
$$
dV = \pi (4y-y^2)dy. 
$$

\end{enumerate}

因此这个容器的总的体积为 
$$
V = \int_{-2}^{1} \pi (4-y^2)dy + \int_{1}^{3} \pi (4y-y^2)dy.
$$

质量等于体积乘以密度，即 $m=\rho V$. 
重量等于质量乘以重力加速度，即 $G=mg$. 
因此体积为 $V$ 的水的重量为 $G=mg=\rho V g$. 
将重量为 $G$ 的物体提升 $h$ 高度，所做的功为 $$W=Gh=mgh=\rho Vgh. $$

将高度为 $y$ 的那层薄薄的水提升到高度为 $3$ 的容器顶部，需要提升的高度为 $3-y$. 
对 $y$ 从 $-2$ 到 $3$ 进行积分，可得所求的总功为 
$$
W = W_1+W_2 = \rho g \int_{-2}^{1} \pi (4-y^2)(3-y)dy + \rho g \int_{1}^{3} \pi (4y-y^2)(3-y)dy.
$$

为计算这个积分，我们使用 Python 的符号计算库 sympy.
其中的 integrate 函数可以计算积分，
Rational(98,10) 是定义了一个符号分式数值 $98/10$. 

\lstinputlisting[language=Python]{ex_2_10_b.py}

计算结果显示容器的总体积为 
$$ V = \frac{49}{3}\pi. $$
将盛满的水从容器顶部抽出需要做的功为
$$ W =\frac{1075550}{3}\pi. $$
%
代入 $\pi$ 进行数值计算，可得
总体积为 $V=51.31$ 立方米，总功为 $W=1.126\times 10^6$ 焦耳。


\section{讨论}

问题：对这个体积和这个做功给一个直观的解释。

\begin{equation*}
\begin{aligned}
1\text{焦耳} &= 1\text{牛顿} \cdot 1\text{米} \\ 
1\text{牛顿} &= 1\text{千克} \cdot 1\text{米}/\text{秒}^2 \\ 
1\text{瓦特} &= 1\text{焦耳}/1\text{秒} \\ 
& \\ 
\text{能量} &= \text{质量}\times \text{速度}^2 \\ 
\text{功率} & = \text{能量}/\text{时间}
\end{aligned}
\end{equation*}

回答：51立方米大概是边长为4米不到一点的一个立方体的体积。
$1.126\times 10^6$ 焦耳的能量，大概是一台1千瓦的功率的抽水机，工作1126秒的时间做的功。
这大概需要 1126/60 = 19分钟的时间。


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{thebibliography}{99}
\bibitem{sishoukui-2} 司守奎, 孙玺菁. \emph{Python数学建模算法与应用}. 国防工业出版社. 2023年2月第1版.
\bibitem{aliyun} 通义千问. \url{https://tongyi.aliyun.com/qianwen/}. 
\end{thebibliography}


\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

